import React, { useState, useEffect } from 'react'
import { Table } from 'antd';


const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
    key: 'id',
  },
  {
    title: '姓名',
    dataIndex: 'name',
    key: 'name',
  },
  {
    title: '年龄',
    dataIndex: 'age',
    key: 'age',
  },
  {
    title: '性别',
    dataIndex: 'gender',
    key: 'gender',
  },
  {
    title: '部门',
    dataIndex: 'department',
    key: 'department',
  },
  {
    title: '职位',
    dataIndex: 'position',
    key: 'position',
  },
];
export default function ShowList() {
  const [list, setList] = useState([])

  useEffect(() => {
    fetch('/api/getList')
      .then(response => response.json())
      .then(json => setList(json.list));
  }, []);

  return (
    <div>
      <h1>员工信息表</h1>
      <Table columns={columns} dataSource={list} />
    </div>
  )
}
